package KDTreeIndex;

public class Key {

	private int[] key;
	private int dimension;
	public Key(int Dimension)
	{
		key=new int[Dimension];
		dimension=Dimension;
	}
	public int getDimension()
	{
		return dimension;
	}
	public int[] getKey()
	{
		return key;
	}
	public void setKey(int[] key)
	{
		this.key=key;
	}
	public int getKey(int Index)
	{
		return key[Index];
	}
	@Override 
	public String toString()
	{
		String s="";
		for(int i:key)
		{
			s+="[";
			s+=i;
			s+="]";
		}
		return s;
	}
	@Override 
	public boolean equals(Object obj)
	{
		boolean result=true;
		for(int i=0;i<key.length;i++)
		{
			Key temp=(Key)obj;
			if(temp.getKey(i)!=key[i])
			{
				result=false;
			}
			}
		return result;
	}
	 @Override 
	    public int hashCode() { 
		 int hash=0;
		 for(int i:key)
		 {
			 hash+=i;
			 hash*=10;
		 }
		 return hash;
	 }
}
